<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button class="createBtn">创建</button>
    <button class="delBtn">销毁</button>
    <script>
      function createArry() {
        var arr = new Array(1024 * 1024).fill(100);

        return function test() {
          console.log(`arr`, arr);
        };
      }
      const totalArr = [];
      const createBtn = document.querySelector(".createBtn");
      const delBtn = document.querySelector(".delBtn");
      createBtn.onclick = function () {
        for (let i = 0; i < 100; i++) {
          totalArr.push(createArry());
        }
      };
      delBtn.onclick = function () {
        totalArr.length = [];
      };
    </script>
  </body>
</html>
